<#include "../../common/header.ftl"/>
<script>
    $(function () {
        // 修改推荐
        $(".inputBtn").click(function () {
            // 清空模态框
            $("#editForm").get(0).reset();
            // 获取json数据
            var josn = $(this).data("json");
            // console.log(josn);
            // 将数据设置到模态框中
            if (josn) {
                $("#editForm input[name='id']").val(josn.id);
                $("#editForm input[name='name']").val(josn.name);
                $("#editForm input[name='grade']").val(josn.grade);
                $("#editForm input[name='count']").val(josn.count);
                $("#editForm input[name='remark']").val(josn.remark);
                $("#editForm select[name='isDisposable']").val(josn.isDisposable + '');
            }
            // 显示模态框
            $("#hotModal").modal("show");
        });
        // 提交表单
        submitForm(".submitBtn", "#editForm");

        // 下拉列表值改变事件
        $("#isDisposableSelect").change(function () {
            // 提交表单
            $("#searchForm").submit();
        });
    });
</script>

</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
            <#-- 往数据模型中填充一个属性 -->
            <#assign menu="integralType"/>
            <#include "../../common/menu.ftl"/>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">积分类型管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/integralType/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>一次性积分:</label>
                    <select class="form-control" name="isDisposable" id="isDisposableSelect">
                        <option value='false'>否</option>
                        <option value='true'>是</option>
                    </select>
                    <script>
                        $("#isDisposableSelect").val('${qo.isDisposable?string("true", "false")}');
                    </script>
                </div>
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                           placeholder="名称/描述"/>
                </div>
                <button class="btn btn-default">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
                <a href="javascript:" class="btn  btn-success inputBtn">
                    <span class="glyphicon glyphicon-plus"></span> 添加
                </a>
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>编号</th>
                    <th>名称</th>
                    <th>对应积分</th>
                    <th>每天限制次数</th>
                    <th>一次性积分</th>
                    <th>描述</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>

                <#-- 循环迭代指令 -->
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.name}</td>
                        <td>${entity.grade}</td>
                        <td>${entity.count}</td>
                        <td>${entity.isDisposable?string("是","否")}</td>
                        <td>${entity.remark}</td>
                        <td>${entity.inputTime?string("yyyy-MM-dd")}</td>
                        <td>
                            <a class="btn btn-info btn-xs inputBtn" data-json='${entity.json}'>
                                <span class="glyphicon glyphicon-pencil"></span> 修改
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../../common/page.ftl"/>
        </div>
    </div>
</div>


<!-- 模态框必须作为body的子标签 -->
<div class="modal fade" id="hotModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">新增/编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/integralType/saveOrUpdate.do" method="post" id="editForm">
                    <!--积分类型的id-->
                    <input type="text" name="id" hidden>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">积分类型名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="name">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">对应积分：</label>
                        <div class="col-sm-6">
                            <input type="number" class="form-control" name="grade">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">每天限制次数：</label>
                        <div class="col-sm-6">
                            <input type="number" class="form-control" name="count">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">一次性积分：</label>
                        <div class="col-sm-6">
                            <select id="auditState" class="form-control" autocomplete="off" name="isDisposable">
                                <option value="false">否</option>
                                <option value="true">是</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">积分类型描述：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="remark">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    <span class="glyphicon glyphicon-off"></span> 关闭
                </button>
                <button type="button" class="btn btn-primary submitBtn">
                    <span class="glyphicon glyphicon-saved"></span> 保存
                </button>
            </div>
        </div>
    </div>
</div>


</body>
</html>